package com.study.service.communication.hystrix;

import com.alibaba.fastjson.JSON;
import com.study.service.communication.AuthorityFeignClient;
import com.study.vo.JwtToken;
import com.study.vo.UsernameAndPassword;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * AuthorityFeignClient 后备 fallback
 */
@Component
@Slf4j
public class AuthorityFeignClientFallback implements AuthorityFeignClient {
    @Override
    public JwtToken getTokenByFeign(UsernameAndPassword usernameAndPassword) {

        log.info("authority feign client get token by feign request error" +
                        "(hystrix fallback) : [{}]", JSON.toJSONString(usernameAndPassword)
                );

        return new JwtToken("getTokenByFeign");

    }
}
